package com.example;

import javax.servlet.*;

public class MyServletContextListener implements ServletContextListener{
	/*
	 *实现将配置文件中的dog对象添加到属性中
	 */
	public void contextInitialized(ServletContextEvent event){
		ServletContext sc = event.getServletContext();
		String dogBreed = sc.getInitParameter("breed");
		Dog dog = new Dog(dogBreed);
		sc.setAttribute("dog",dog);
	}
	
	public void contextDestroyed(ServletContextEvent event){
		//nothing to do
	}
}